#encoding=utf8
'''
Created on 2012-9-21

@author: Administrator
'''
from pub import Func
from pub.Config import Config
from twisted.protocols.basic import LineReceiver
class Processor(object):
    '''
    classdocs
    '''


    def __init__(self,):
        '''
        Constructor
        '''
        self._cmd = "None" 
        self._cmdId = None
        self._cmdContent = None
        self._sockObj = None
    def dataValidtor(self, cmdContent):
        raise NotImplementedError;
    
    
    def setPackage(self, data=[]):
        '''
                        组装数据
        @param data:数据源
        @return:String 
        '''
        resultStr = Func.toStr(self._cmd) + "#" + Func.toStr(self._cmdId);
        for tmp in data:
            resultStr = resultStr + "#" + Func.toStr(tmp);
        return resultStr;
    

    def getData(self, cmd, cmdId, cmdContent, sockObj):
        '''
        u'接收命令数据
        @param cmdId integer 传回的命令编号:
        @param cmdContent list 命令所使用的数据内容:  
        '''
        if not self.dataValidtor(cmdContent):
#            sockObj.sendLine("command valid error");
            return
        self._cmd = cmd
        self._cmdId = cmdId
        self._cmdContent = cmdContent
        self._sockObj = sockObj
        Func.debugInfo(self._sockObj)
        

    def outData(self):
        '''
        u'输出逻辑处理后的数据
        '''
        return Config.I_SYS_ONE;
